Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing

Imports System.Windows.Forms.Design
Imports System.ComponentModel.Design
Imports System.Drawing.Design

Imports System.Windows.Forms


Namespace Phoenix.Tools.Backup
	Public Class WelcomePage : Inherits Phoenix.Tools.WizardPageBase
		#Region "Form controls"
		Private chkDontShow As System.Windows.Forms.CheckBox
		Private lblDescription2 As System.Windows.Forms.Label
		Private lblDescription As System.Windows.Forms.Label
		Private lblHint As System.Windows.Forms.Label
		Private lblWizardName As System.Windows.Forms.Label
		Private imgWelcome As System.Windows.Forms.PictureBox
		Private components As System.ComponentModel.IContainer = Nothing
		#End Region

		#Region "Class Properties"
		Public Manager As OperationManager

		Protected Overrides ReadOnly Property DefaultSize() As System.Drawing.Size
			Get
				Return New Size(498, 328)
			End Get
		End Property

		<Browsable(True), Category("Wizard Page"), Description("Is checkbox ""Don't show..."" checked."), DefaultValue(False)> _
		Public Property DontShow() As Boolean
			Get
				Return chkDontShow.Checked
			End Get
			Set
				If Value <> chkDontShow.Checked Then
					chkDontShow.Checked = Value
					OnDontShowChanged()
					OnChanged()
				End If
			End Set
		End Property

		<Browsable(True), Category("Wizard Page"), Description("Gets/Sets wizard page second description Text. This description used only by welocme and final pages")> _
		Public Property Description2() As String
			Get
				' if control not intialized yet
				If lblDescription2 Is Nothing Then
				Return String.Empty
				End If

				Return lblDescription2.Text
			End Get
			Set
				' skip text set if control not created yet
				If lblDescription2 Is Nothing Then
				Return
				End If

				If Value <> lblDescription2.Text Then
					lblDescription2.Text = Value
					OnDescription2Changed()
				End If
			End Set
		End Property
		#End Region

		#Region "Class Initialize/Finilize methods"
		Public Sub New()
			InitializeComponent()

			Me.Size = New Size(498, 328)
			Me.Name = "wizWelcomePage"
			MyBase.WelcomePage = True

			MyBase.Title = lblWizardName.Text
			MyBase.Description = lblDescription.Text
			MyBase.HeaderImage = imgWelcome.Image

			AddHandler lblDescription2.SizeChanged, AddressOf OnLabelSizeChanged
		End Sub

		Protected Overrides Overloads Sub Dispose(ByVal disposing As Boolean)
			If disposing AndAlso Not components Is Nothing Then
				components.Dispose()
			End If

			MyBase.Dispose(disposing)
		End Sub
		#End Region

		#Region "Designer generated code"
		''' <summary>
		''' Required method for Designer support - do not modify
		''' the contents of this method with the code editor.
		''' </summary>
		Private Sub InitializeComponent()
			Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(WelcomePage))
			Me.chkDontShow = New System.Windows.Forms.CheckBox()
			Me.lblDescription2 = New System.Windows.Forms.Label()
			Me.lblDescription = New System.Windows.Forms.Label()
			Me.lblHint = New System.Windows.Forms.Label()
			Me.lblWizardName = New System.Windows.Forms.Label()
			Me.imgWelcome = New System.Windows.Forms.PictureBox()
			Me.SuspendLayout()
			' 
			' chkDontShow
			' 
			Me.chkDontShow.Anchor = (CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles))
			Me.chkDontShow.BackColor = System.Drawing.Color.Transparent
			Me.chkDontShow.Location = New System.Drawing.Point(200, 611)
			Me.chkDontShow.Name = "chkDontShow"
			Me.chkDontShow.Size = New System.Drawing.Size(631, 16)
			Me.chkDontShow.TabIndex = 9
			Me.chkDontShow.Text = "&Do not show this Welcome page again"
			' 
			' lblDescription2
			' 
			Me.lblDescription2.Anchor = (CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles))
			Me.lblDescription2.BackColor = System.Drawing.Color.Transparent
			Me.lblDescription2.Location = New System.Drawing.Point(200, 176)
			Me.lblDescription2.Name = "lblDescription2"
			Me.lblDescription2.Size = New System.Drawing.Size(631, 127)
			Me.lblDescription2.TabIndex = 7
			Me.lblDescription2.Text = "Please note: you can restore the Phoenix database upon existing one only. You can" & " not create a new database instalation with the Backup or Restore Wizard."
			' 
			' lblDescription
			' 
			Me.lblDescription.Anchor = (CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles))
			Me.lblDescription.BackColor = System.Drawing.Color.Transparent
			Me.lblDescription.Location = New System.Drawing.Point(200, 120)
			Me.lblDescription.Name = "lblDescription"
			Me.lblDescription.Size = New System.Drawing.Size(631, 32)
			Me.lblDescription.TabIndex = 6
			Me.lblDescription.Text = "This wizard helps you back up or restore the Phoenix configuratin data and Databa" & "se."
			' 
			' lblHint
			' 
			Me.lblHint.Anchor = (CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles))
			Me.lblHint.BackColor = System.Drawing.Color.Transparent
			Me.lblHint.Location = New System.Drawing.Point(200, 587)
			Me.lblHint.Name = "lblHint"
			Me.lblHint.Size = New System.Drawing.Size(631, 16)
			Me.lblHint.TabIndex = 8
			Me.lblHint.Text = "To continue, click Next"
			Me.lblHint.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
			' 
			' lblWizardName
			' 
			Me.lblWizardName.Anchor = (CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles))
			Me.lblWizardName.BackColor = System.Drawing.Color.Transparent
			Me.lblWizardName.Font = New System.Drawing.Font("Tahoma", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (CByte(204)))
			Me.lblWizardName.Location = New System.Drawing.Point(200, 16)
			Me.lblWizardName.Name = "lblWizardName"
			Me.lblWizardName.Size = New System.Drawing.Size(631, 104)
			Me.lblWizardName.TabIndex = 5
			Me.lblWizardName.Text = "Welcome to the Backup or Restore Wizard"
			' 
			' imgWelcome
			' 
			Me.imgWelcome.Dock = System.Windows.Forms.DockStyle.Left
			Me.imgWelcome.Image = (CType(resources.GetObject("imgWelcome.Image"), System.Drawing.Image))
			Me.imgWelcome.Location = New System.Drawing.Point(0, 0)
			Me.imgWelcome.Name = "imgWelcome"
			Me.imgWelcome.Size = New System.Drawing.Size(184, 635)
			Me.imgWelcome.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
			Me.imgWelcome.TabIndex = 14
			Me.imgWelcome.TabStop = False
			' 
			' WelcomePage
			' 
			Me.BackColor = System.Drawing.Color.White
			Me.Controls.Add(Me.imgWelcome)
			Me.Controls.Add(Me.chkDontShow)
			Me.Controls.Add(Me.lblDescription2)
			Me.Controls.Add(Me.lblDescription)
			Me.Controls.Add(Me.lblHint)
			Me.Controls.Add(Me.lblWizardName)
			Me.Name = "WelcomePage"
			Me.Size = New System.Drawing.Size(849, 635)
'			Me.Next += New Phoenix.Tools.WizardForm.WizardNextEventHandler(Me.WelcomePage_Next);
			Me.ResumeLayout(False)

		End Sub
		#End Region

		#Region "Class helper methods"
		Private Sub OnLabelSizeChanged(ByVal sender As Object, ByVal e As EventArgs)
			OnResize(e)
		End Sub
		#End Region

		#Region "Class Overrides"
		Protected Overrides Sub OnResize(ByVal e As System.EventArgs)
			MyBase.OnResize(e)

			If Not Description2 Is Nothing AndAlso Description2.Length > 0 Then
				Dim bmp As Bitmap = New Bitmap(lblDescription2.Width, lblDescription2.Height)
				Dim g As Graphics = Graphics.FromImage(bmp)
				'this.CreateGraphics();

				Dim format As StringFormat = New StringFormat()
				format.Trimming = StringTrimming.Word

				Dim size As SizeF = g.MeasureString(Description2, lblDescription2.Font, lblDescription2.Width, format)

				lblDescription2.Height = CInt(size.Height) + 16
				lblHint.Top = lblDescription2.Bottom + 8

				g.Dispose()
				bmp.Dispose()
			End If
		End Sub
		Protected Friend Overrides Sub OnPageShown()
			WizardPageParent.WizardButtons = WizardForm.TWizardsButtons.Next Or WizardForm.TWizardsButtons.Cancel
		End Sub
		'
			'protected override void OnImageListChanged()
			'{
			  'if( base.ImageList != null )
			  '{
				'if( base.ImageIndex >= 0 && ImageIndex < base.ImageList.Images.Count )
				'{
				  'imgWatermark.Image = base.ImageList.Images[ base.ImageIndex ];
				'}
			  '}
			'}

			'protected override void OnImageIndexChanged()
			'{
			  'if( base.ImageList != null )
			  '{
				'if( base.ImageIndex >= 0 && ImageIndex < base.ImageList.Images.Count )
				'{
				  'imgWatermark.Image = base.ImageList.Images[ base.ImageIndex ];
				'}
			  '}
			'}
		'
		Protected Overrides Sub OnHeaderImageChanged()
			imgWelcome.Image = MyBase.HeaderImage
		End Sub

		Protected Overrides Sub OnTitleChanged()
			lblWizardName.Text = MyBase.Title
		End Sub

		Protected Overrides Sub OnDescriptionChanged()
			lblDescription.Text = MyBase.Description
		End Sub

		Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
			OnImageListChanged()
			OnHeaderImageChanged()
			MyBase.OnLoad(e)
		End Sub
		Protected Overridable Sub OnDescription2Changed()
			OnResize(EventArgs.Empty)
		End Sub

		Protected Overridable Sub OnDontShowChanged()

		End Sub
		#End Region

		#Region "Event Handlers"
        Private Sub WelcomePage_Next(ByVal sender As Object, ByVal e As Phoenix.Tools.WizardForm.EventNextArgs) Handles MyBase.NextEvent
            Manager.ShowWelcomePage = Not DontShow
        End Sub
#End Region


	End Class
End Namespace

